from PyQt5.QtWidgets import QWidget

# 导入窗体内容
from design.personalInfoDlg import *

from common.logger import logger
from common.retcode import RetCode
from common.utils import get_file_size_str, center_window_on_screen

# 创建 MainWin 类并传入Ui_MainWindow
class PersonalInfoDlg(QWidget, Ui_PersonalInfoDlg):
	def __init__(self, parent=None):
		super(PersonalInfoDlg, self).__init__(parent)
		self.setupUi(self)
		center_window_on_screen(self)

	def setUserInfo(self, user_info):
		self.labelUserId.setText(f'{user_info.id}')
		self.labelAccount.setText(user_info.account)
		self.labelNickName.setText(user_info.nickname if len(user_info.nickname) > 0 else '未设置')
		self.labelDiskUsage.setText(f'{get_file_size_str(user_info.used)} / {get_file_size_str(user_info.quota)}')
		self.labelVip.setText(f'{user_info.vip}级')
		self.labelLastLogined.setText(user_info.beginTime)
		self.labelValidUntil.setText(user_info.endTime)
